<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:p="http://primefaces.org/ui"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:pe="http://primefaces.org/ui/extensions">

    <pe:head>
        <title>#{bundle.savtrxgl}</title>
        <link href="./resources/css/default.css" rel="stylesheet" type="text/css" />
        
    </pe:head>
    <h:body>
        
    <ui:composition>    
            <h:form>
               <script type="text/javascript">  
                    function handleSaveSavtrxgl(xhr, status, args) {  
                        if(args.validationFailed || !args.success) {  
                            jQuery('#dialog').effect("shake", { times:3 }, 100);  
                        } else {  
                            dlgSavtrxgl.hide();  
                        }  
                    }

                    function handleDeleteSavtrxgl(xhr, status, args) {  
                        if(args.validationFailed || !args.success) {  
                            jQuery('#dialog').effect("shake", { times:3 }, 100);  
                        } else {  
                            dlgDelSavtrxgl.hide();  
                        }  
                    }
                    
                </script>

                <p:toolbar>
                    <p:toolbarGroup align="left">
                         <p:commandButton value="#{bundle.btnNew}" icon="ui-icon-document" 
                                         action="#{savtrxglBean.newData()}" oncomplete="dlgSavtrxgl.show();" 
                                         rendered="#{menuBean.cekButtonAccess(183,'INS;')}"
                                         update=":#{utilityBean.findClientId('displaySavtrxgl')}" process="@this">
                            <pe:resetEditableValues for="displaySavtrxgl" />  
                        </p:commandButton>   
                  
                        <p:commandButton value="#{bundle.btnOpen}" oncomplete="dlgSavtrxgl.show()"
                                         actionListener="#{savtrxglBean.openData()}"
                                         rendered="#{menuBean.cekButtonAccess(183,'OPN;')}"
                                         icon="ui-icon-disk" 
                                         update=":#{utilityBean.findClientId('displaySavtrxgl')}" /> 

                        <p:commandButton type="button" value="#{bundle.btnDelete}" icon="ui-icon-trash"
                                         onclick="dlgDelSavtrxgl.show()"
                                         update="displaySavtrxgl" /> 
                    </p:toolbarGroup>
                </p:toolbar>

                <p:dataTable var="savtrxgl" value="#{savtrxglBean.savtrxgls}" id="dtSavtrxgls"
                             selection="#{savtrxglBean.selectedData}" selectionMode="single" rowKey="#{savtrxgl.savtrxglId}" 
                             resizableColumns="true" rowIndexVar="noUrut" >
                    
                    <p:column style="width:15px;" >
                        <f:facet name="header">No.</f:facet>
                        <h:outputText value="#{noUrut+1}" />
                    </p:column>
                    
                    <p:column style="width:200px;" sortBy="#{savtrxgl.transactionName}">
                        <f:facet name="header">#{bundle.transactionName}</f:facet>
                        <h:outputText value="#{savtrxgl.transactionName}" />
                    </p:column>
                    
                    <p:column style="width:100px;">
                        <f:facet name="header">#{bundle.glaccnt}</f:facet>
<!--                        <h:outputText value="#{savtrxglBean.selectItemValueOf(savtrxgl.glaccount.glaccntId)}" />-->
                        <h:outputText value="#{savtrxgl.glaccount.accountName}" />
                    </p:column>
                </p:dataTable>
           
                <p:confirmDialog message="#{bundle.confirmDelete}" 
                                 header="#{bundle.confirmDeleteHeader}" severity="alert" widgetVar="dlgDelSavtrxgl">  
                    <p:commandButton value="#{bundle.btnYes}" update="dtSavtrxgls" 
                                     oncomplete="handleDeleteSavtrxgl(xhr, status, args)"  
                                     actionListener="#{savtrxglBean.delete()}" />  
                    <p:commandButton value="#{bundle.btnCancel}" onclick="dlgDelSavtrxgl.hide()" type="button" />   
                </p:confirmDialog> 
                </h:form>
                
            <p:dialog header="#{bundle.savtrxgl}" widgetVar="dlgSavtrxgl" closable="true" dynamic="true" appendToBody="true" modal="true">
                    <p:ajax event="close" listener="#{savtrxglBean.handleClose}"/>
                    <h:form>
                    <h:panelGrid id="displaySavtrxgl" columns="3" styleClass="addELIT" cellpadding="0" cellspacing="5">
                        <!-- -->
                        <h:outputLabel value= "#{bundle.transactionName}" /><h:outputLabel value= ":" />
                        <p:selectOneMenu value="#{savtrxglBean.unsaveData.transactionName}" style="width: 170px" rendered="#{savtrxglBean.unsaveData!=null}"
                                         requiredMessage="#{bundle.transactionName} #{bundle.requiredInput}" id="savtrxglTransactionName"
                                         required="true" label="#{bundle.transactionName}" >
                            <f:selectItems value="#{savtrxglBean.avblName}" />
                        </p:selectOneMenu>

                        <h:outputLabel style="padding: 0 15px 0 0" value= "#{bundle.glaccnt}" /><h:outputLabel value= ":" />
                        <p:selectOneMenu value="#{savtrxglBean.unsaveData.glaccount}" style="width: 300px" rendered="#{savtrxglBean.unsaveData!=null}"
                                         requiredMessage="#{bundle.glaccnt} #{bundle.requiredInput}" id="savtrxglGlaccnt1" 
                                         required="true" label="#{bundle.glaccnt}" converter="glaccnt" var="gl">
                            <f:selectItem rendered="#{savtrxglBean.unsaveData.glaccount!=null}" itemLabel="#{savtrxglBean.unsaveData.glaccount.accountName}" itemValue="#{savtrxglBean.unsaveData.glaccount}" />
                            <f:selectItems value="#{savtrxglBean.avblGL}" var="glacc" itemLabel="#{glacc.accountName}" itemValue="#{glacc}"/>

                            <p:column>#{gl.accountNo}</p:column>
                            <p:column>#{gl.accountName}</p:column>
                            
                        </p:selectOneMenu>
                    </h:panelGrid>

                    <h:panelGrid cellpadding="0" styleClass="pComBtnSTDR">
                        <f:facet name="footer">
                            <p:commandButton value="#{bundle.btnSave}" icon="ui-icon-disk" actionListener="#{savtrxglBean.save()}"
                                             update=":#{utilityBean.findClientId('dtSavtrxgls')}" id="submitSavtrxgl"
                                             oncomplete="handleSaveSavtrxgl(xhr, status, args)"/>
                            <p:commandButton value="#{bundle.btnClose}" oncomplete="dlgSavtrxgl.hide()" icon="ui-icon-document" process="@this" >
                                <pe:resetEditableValues for="displaySavtrxgl"/>
                            </p:commandButton>
                        </f:facet>
                    </h:panelGrid>
                   <p:defaultCommand target="submitSavtrxgl" /> 
                   </h:form>
                </p:dialog> 
                    
        </ui:composition>    
    </h:body>
</html>
